clear
use Data3.dta
save temp.dta, replace


*Figure 5
clear
use temp.dta
keep if party2==1
twoway (scatter vshare over65, msize(small)) (lfit vshare over65, lcolor(black)), legend(off) graphregion(color(white)) xtitle(65 and Above(%)) ytitle(LDP Candidate's Vote Share (%))

*Table 4
clear
use temp.dta
local control=" i.party2 age male term"
reg q6_5  over60 manufacturing `control', robust
outreg2 using a.txt, replace

reg q6_5  over65 manufacturing `control', robust
outreg2 using a.txt, append

reg q6_5  over70 manufacturing `control', robust
outreg2 using a.txt, append

reg q6_5  over60 manufacturing `control' if rank==1, robust
outreg2 using a.txt, append

reg q6_5  over65 manufacturing `control' if rank==1, robust
outreg2 using a.txt, append

reg q6_5  over70 manufacturing `control' if rank==1, robust
outreg2 using a.txt, append

*Appendix E
clear
use temp.dta
tab q6_5 party2, col


*Appendix F1
clear
use temp.dta
local control="i.party2 age male term"

reg q6_5  over60, robust
outreg2 using a.txt, replace

reg q6_5  over65, robust
outreg2 using a.txt, append

reg q6_5  over70, robust
outreg2 using a.txt, append

reg q6_5  over60 manufacturing, robust
outreg2 using a.txt, append

reg q6_5  over65 manufacturing, robust
outreg2 using a.txt, append

reg q6_5  over70 manufacturing, robust
outreg2 using a.txt, append

reg q6_5  over60 manufacturing `control', robust
outreg2 using a.txt, append

reg q6_5  over65 manufacturing `control', robust
outreg2 using a.txt, append

reg q6_5  over70 manufacturing `control', robust
outreg2 using a.txt, append

reg q6_5  over60 if rank==1, robust
outreg2 using a.txt, append

reg q6_5  over65 if rank==1, robust
outreg2 using a.txt, append

reg q6_5  over70 if rank==1, robust
outreg2 using a.txt, append

reg q6_5  over60 manufacturing if rank==1, robust
outreg2 using a.txt, append

reg q6_5  over65 manufacturing if rank==1, robust
outreg2 using a.txt, append

reg q6_5  over70 manufacturing if rank==1, robust
outreg2 using a.txt, append

reg q6_5  over60 manufacturing `control' if rank==1, robust
outreg2 using a.txt, append

reg q6_5  over65 manufacturing `control' if rank==1, robust
outreg2 using a.txt, append

reg q6_5  over70 manufacturing `control' if rank==1, robust
outreg2 using a.txt, append


*Appendix F2
clear
use temp.dta
local control="i.party2 age male term"
ologit q6_5  over60 manufacturing `control', robust
outreg2 using a.txt, e(r2_p) replace

ologit q6_5  over65 manufacturing `control', robust
outreg2 using a.txt, e(r2_p)  append

ologit q6_5  over70 manufacturing `control', robust
outreg2 using a.txt, e(r2_p) append

ologit q6_5  over60 manufacturing `control' if rank==1, robust
outreg2 using a.txt, e(r2_p) append

ologit q6_5  over65 manufacturing `control' if rank==1, robust
outreg2 using a.txt, e(r2_p) append

ologit q6_5  over70 manufacturing `control' if rank==1, robust
outreg2 using a.txt, e(r2_p) append


*Appendix F3
clear
use temp.dta
mlogit q6_5  over60 manufacturing i.party2 age male term, robust base(3)
outreg2 using a.txt, e(r2_p) replace

mlogit q6_5  over65 manufacturing i.party2 age male term, robust  base(3)
outreg2 using a.txt, e(r2_p)  append

mlogit q6_5  over70 manufacturing i.party2 age male term, robust  base(3)
outreg2 using a.txt, e(r2_p) append

mlogit q6_5  over60 manufacturing i.party2 age male term if rank==1, robust  base(3)
outreg2 using a.txt, e(r2_p) append

mlogit q6_5  over65 manufacturing i.party2 age male term if rank==1, robust  base(3)
outreg2 using a.txt, e(r2_p) append

mlogit q6_5  over70 manufacturing i.party2 age male term if rank==1, robust  base(3)
outreg2 using a.txt, e(r2_p) append


*Appendix F4
clear
use temp.dta
local control="i.party2 age male term"
logit Y  over60 manufacturing `control', robust
outreg2 using a.txt, e(r2_p) replace

logit Y  over65 manufacturing `control', robust
outreg2 using a.txt, e(r2_p)  append

logit Y  over70 manufacturing `control', robust
outreg2 using a.txt, e(r2_p) append

logit Y  over60 manufacturing `control' if rank==1, robust
outreg2 using a.txt, e(r2_p) append

logit Y  over65 manufacturing `control' if rank==1, robust
outreg2 using a.txt, e(r2_p) append

logit Y  over70 manufacturing `control' if rank==1, robust
outreg2 using a.txt, e(r2_p) append


*Appendix F5, Table F5(1)
clear
use temp.dta
reg q6_5  c.over65 c.over65#c.over65  manufacturing i.party2 age male term, robust
outreg2 using a.txt, replace

reg q6_5 c.over65 c.manufacturing  LDP  age male term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP c.term#c.over65, robust
outreg2 using a.txt, append

reg q6_5  c.over65 c.over65#c.over65  manufacturing i.party2 age male term if rank==1, robust
outreg2 using a.txt, append

reg q6_5 c.over65 c.manufacturing  LDP  age male term   c.over65#c.manufacturing   c.over65#i.LDP c.term#c.over65 if rank==1, robust
outreg2 using a.txt, append 


*Appendix F5, Table F5(2)
clear
use temp.dta
logit Y  c.over65 c.over65#c.over65  manufacturing i.party2 age male term, robust
outreg2 using a.txt, replace

logit Y c.over65 c.manufacturing  LDP  age male term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP c.term#c.over65, robust 
outreg2 using a.txt, append e(r2_p)

logit Y  c.over65 c.over65#c.over65  manufacturing i.party2 age male term if rank==1, robust
outreg2 using a.txt, append e(r2_p)

logit Y c.over65 c.manufacturing  LDP  age male term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP c.term#c.over65 if rank==1, robust 
outreg2 using a.txt, append e(r2_p)


*Appendix F5, Figure 5(1)
clear
use temp.dta
logit Y  c.over65 c.over65#c.over65  manufacturing i.party2 age male term, robust
margins, at(over65=(16(2)34)) 
marginsplot, noci recast(line)  xtitle(Elderly (%)) ytitle(Probability of disapproval)  title(All candidates)
graph save 1, replace

logit Y  c.over65 c.over65#c.over65   manufacturing i.party2 age male term if rank==1, robust
margins, at(over65=(16(2)34))
marginsplot, noci recast(line)   xtitle(Elderly (%)) ytitle(Probability of disapproval)  title(Elected candidates)
graph save 2, replace

graph combine 1.gph 2.gph, xcom ycom


*Appendix F5, Figure 5(2)
clear
use temp.dta
logit Y c.over65 c.manufacturing  i.LDP  age male term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP c.term#c.over65, robust
margins, at(over65=(16(2)34) manufacturing=(5 20 35))
marginsplot, recast(line) noci xtitle(Elderly (%)) ytitle(Probability of disapproval) legend(title(Manufacturing sector (%), size(medium)) size(small) order(1 "5%" 2 "20%" 3 "35%")) plot1opt(lpattern(dash)) plot3opt(lcolor(black) lpattern(dot)) title(All candidates)
graph save 1, replace

logit Y c.over65 c.manufacturing  i.LDP  age male term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP c.term#c.over65 if rank==1, robust
margins, at(over65=(16(2)34) manufacturing=(5 20 35))
marginsplot, recast(line) noci xtitle(Elderly (%)) ytitle(Probability of disapproval) legend(title(Manufacturing sector (%), size(medium)) size(small) order(1 "5%" 2 "20%" 3 "35%")) plot1opt(lpattern(dash)) plot3opt(lcolor(black) lpattern(dot)) title(Elected candidates)
graph save 2, replace

graph combine 1.gph 2.gph, xcom ycom

*Appendix F5, Figure 5(3)
clear
use temp.dta
logit Y c.over65 c.manufacturing  i.LDP  age male term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP c.term#c.over65, robust
margins, at(over65=(16(2)34) vshare=(30 40 50 60 70))
marginsplot, recast(line) noci xtitle(Elderly (%)) ytitle(Probability of disapproval) legend(title(Candidate vote share (%), size(small)) size(small) order(1 "30%" 2 "40%" 3 "50%" 4 "60%" 5 "70%")) plot1opt(lpattern(dash)) plot3opt(lcolor(black) lpattern(dot)) title(All candidates)
graph save 1, replace

logit Y c.over65 c.manufacturing  i.LDP  age male term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP c.term#c.over65 if rank==1, robust
margins, at(over65=(16(2)34) vshare=(30 40 50 60 70))
marginsplot, recast(line) noci xtitle(Elderly (%)) ytitle(Probability of disapproval) legend(title(Candidate vote share (%), size(small)) size(small) order(1 "30%" 2 "40%" 3 "50%" 4 "60%" 5 "70%")) plot1opt(lpattern(dash)) plot3opt(lcolor(black) lpattern(dot)) title(Elected candidates)
graph save 2, replace

graph combine 1.gph 2.gph, xcom ycom


*Appendix F5, Figure 5(4)
clear
use temp.dta
logit Y c.over65 c.manufacturing  i.LDP  age male term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP c.term#c.over65, robust
margins, at(over65=(16(2)34) term=(0 1 3 5 7 9))
marginsplot, recast(line) noci xtitle(Elderly (%)) ytitle(Probability of disapproval) legend(title(Seniority, size(medium))  order(1 "0 term (challenger)" 2 "1 term" 3 "3 terms" 4 "5 terms" 5 "7 terms" 6 "9 terms")) plot1opt(lpattern(dash)) plot3opt(lcolor(black) lpattern(dot)) title(All candidates)
graph save 1, replace

logit Y c.over65 c.manufacturing  i.LDP  age male term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP c.term#c.over65 if rank==1, robust
margins, at(over65=(16(2)34) term=(0 1 3 5 7 9))
marginsplot, recast(line) noci xtitle(Elderly (%)) ytitle(Probability of disapproval) legend(title(Seniority, size(medium))  order(1 "0 term (challenger)" 2 "1 term" 3 "3 terms" 4 "5 terms" 5 "7 terms" 6 "9 terms")) plot1opt(lpattern(dash)) plot3opt(lcolor(black) lpattern(dot)) title(Elected candidates)
graph save 2, replace

graph combine 1.gph 2.gph, xcom ycom


*Appendix F5, Figure 5(5)
clear
use temp.dta
logit Y c.over65 c.manufacturing  i.LDP  age male i.term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP i..term#c.over65, robust

margins, at(over65=(16(2)34) LDP=(0 1))
marginsplot, recast(line) noci xtitle(Elderly (%)) ytitle(Probability of disapproval) legend(title(LDP, size(medium))  order(1 "Non-LDP" 2 "LDP")) plot1opt(lpattern(dash)) plot2opt(lcolor(black) lpattern(solid)) title(All candidates)
graph save 1, replace

logit Y c.over65 c.manufacturing  i.LDP  age male i.term  vshare c.over65#c.manufacturing  c.over65#c.vshare c.over65#i.LDP i..term#c.over65 if rank==1, robust

margins, at(over65=(16(2)34) LDP=(0 1))
marginsplot, recast(line) noci xtitle(Elderly (%)) ytitle(Probability of disapproval) legend(title(LDP, size(medium))  order(1 "Non-LDP" 2 "LDP")) plot1opt(lpattern(dash)) plot2opt(lcolor(black) lpattern(solid)) title(Elected candidates)
graph save 2, replace

graph combine 1.gph 2.gph, xcom ycom
